package com.itheima.web.session; /**
 * @author Xiao
 * @date 2021/8/31
 */

import com.itheima.web.pojo.UserDemo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/**session基本使用*/
@WebServlet("/session01a")
public class SessionDemo01a extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        session.setAttribute("username", "张三");
        session.setAttribute("age", 23);
        UserDemo user = new UserDemo();
        user.setName("阿良");
        user.setAge(18);
        session.setAttribute("user", user);
        System.out.println(session);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
